package com.sunducation.co.mcvw;

import lombok.Data;

import java.util.Arrays;
import java.util.Date;

/**
 * @description: 演示---内部存在可变对象引起的BUG
 * @author:chenwenbiao
 * @createTime:2019/7/9 14:33
 * @Version：1.0
 **/
@Data
public class MutableObjectTest {

    private Integer[] ids;
    private Date gmtCreate;

    public static void main(String[] argv){
        MutableObjectTest mutableObjectTest = new MutableObjectTest();
        Date date = new Date();
        mutableObjectTest.setGmtCreate(date);

        System.out.println(mutableObjectTest.getGmtCreate());
        date.setYear(12);
        System.out.println(mutableObjectTest.getGmtCreate());

        Integer[] ids = {1,2,3};
        mutableObjectTest.setIds(ids);

        System.out.println(Arrays.asList(mutableObjectTest.getIds()));
        ids[1] = 0;
        System.out.println(Arrays.asList(mutableObjectTest.getIds()));

    }

}
